<%@page import="java.util.Collection"%>
<%@page import="java.util.ArrayList"%>
<%@page import="DBModule.*" %>
<%@page import="Test.*"%>
<%@page import="java.util.Iterator"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% request.setCharacterEncoding("UTF-8"); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<script language="JavaScript" src="js/check.js" type="text/javascript"></script>
<script language="JavaScript">
	function check(){
		var arr = [
		check_checkFun("userID", /^\d{1,8}$/, "ID不能超过8位且为纯数字"),
		check_checkFun("userName", /^[\u4e00-\u9fa5]{1,4}$/, "姓名需为中文字符且不超过4个字符"),
		check_checkFun("password", /^\w{1,20}$/, "密码不能为空且不超过20个字符"),
		check_checkFun("repeat", new RegExp("^"+document.getElementsByName("password")[0].value+"$"), "两次输入密码不同"),
		check_checkFun("phone", /^1\d{10}$/, "手机格式为：1xxxxxxxxxx"),
		check_checkFun("email", /^.{1,20}$/, "E-Mail长度不能超过20个字符"),
		check_checkFun("email", /^\w+@\w+\.com$/, "E-Mail格式错误"),
		check_checkFun("dept", /^.{1,10}$/, "系名不超过10个字符且不为空"),
		];
		return true;
		return check_check(arr);
	}
	
</script>

</head>
<body bgcolor="silver">
<center>
	<form action="UserServlet?method=register" method="post" onsubmit="return check();">
	<table border="1">
		<tr>
			<th>ID</th>
			<td><input name="userID" /></td>
		</tr>
		<tr>
			<th>名字</th>
			<td><input name="userName" /></td>
		</tr>
		<tr>
			<th>密码</th>
			<td><input name="password" type="password" /></td>
		</tr>
		<tr>
			<th>再输入一次密码</th>
			<td><input name="repeat" type="password" /></td>
		</tr>
		<tr>
			<th>所在系</th>
			<td><input name="dept"></td>
		</tr>
		<tr>
			<th>电话</th>
			<td><input name="phone"></td>
		</tr>
		<tr>
			<th>邮箱</th>
			<td><input name="email"></td>
		</tr>
		<tr>
			<th>类型</th>
			<td>
				学生：<input type="radio" name="type" value="Student" checked />
				教师：<input type="radio" name="type" value="Teacher" />
			</td>
		</tr>
		<tr>
			
	<%
					Collection<Course> set = CourseTable.getAllCourse();
						out.println(String.format("<th rowspan=\"%d\">所选课程</th>", set.size()+1));
						String format = "<tr><td>%s:<input type=\"checkbox\" name=\"course\" value=\"%d\"></td></tr>";
						Iterator<Course> iter = set.iterator();
						while (iter.hasNext()){
					Course c = iter.next();
					out.println(String.format(format, c.getName(), c.getId()));
						}
				%>
		</tr>
		
	</table>
	<input type="submit" value="提交">
	</form>
</center>
</body>
</html>

